package com.ricervcvcer.order.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ricervcvcer.order.entity.OrderStatusEntity;
import com.ricervcvcer.order.service.OrderStatusService;
import com.ricervcvcer.order.util.PageUtils;
import com.ricervcvcer.order.util.R;
import com.ricervcvcer.order.vo.OrderStatusVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 订单状态表
 *
 * @author wlh
 * @email wlhstudy@163.com
 * @date 2022-03-04 10:10:57
 */
@RestController
@RequestMapping("/orderstatus")
public class OrderStatusController {
    @Autowired
    private OrderStatusService orderStatusService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderStatusService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orderId}")
    public R info(@PathVariable("orderId") Long orderId){
		OrderStatusEntity orderStatus = orderStatusService.getById(orderId);

        return R.ok().put("orderStatus", orderStatus);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OrderStatusEntity orderStatus){
		orderStatusService.save(orderStatus);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody OrderStatusVo orderStatusVo){
		orderStatusService.updateByOrderId(orderStatusVo);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] orderIds){
		orderStatusService.removeByIds(Arrays.asList(orderIds));

        return R.ok();
    }

}
